﻿using System;
using fastCSharp;
using fastCSharp.code.cSharp;

namespace diantou.dataModel.path
{
    /// <summary>
    /// 问题URL
    /// </summary>
    public struct question
    {
        /// <summary>
        /// 问题标识
        /// </summary>
        public int Id;
        /// <summary>
        /// 重定向问题标识
        /// </summary>
        public int LinkId;
        /// <summary>
        /// 格式化URL
        /// </summary>
        /// <param name="name">页面名称</param>
        /// <param name="id">问题标识</param>
        /// <returns></returns>
        private webView.hashUrl get(string name, int id)
        {
            return new webView.hashUrl { Path = "/question/" + name + ".html", Query = "questionId=" + id.toString() };
        }
        /// <summary>
        /// 格式化URL
        /// </summary>
        /// <param name="name">页面名称</param>
        /// <returns></returns>
        private webView.hashUrl get(string name)
        {
            return get(name, Id);
        }
        /// <summary>
        /// 首页
        /// </summary>
        public webView.hashUrl IndexNoLink
        {
            get { return get("index"); }
        }
        /// <summary>
        /// 首页
        /// </summary>
        public webView.hashUrl Index
        {
            get
            {
                if (LinkId == 0) return IndexNoLink;
                webView.hashUrl index = get("index", LinkId);
                return new webView.hashUrl { Path = index.Path, Query = index.Query + "&linkId=" + Id.toString() };
            }
        }
        /// <summary>
        /// 日志
        /// </summary>
        public webView.hashUrl Log
        {
            get
            {
                return get("log", Id);
            }
        }
        /// <summary>
        /// 关注者
        /// </summary>
        public webView.hashUrl Focus
        {
            get
            {
                return get("focus", Id);
            }
        }
        /// <summary>
        /// 相关收藏
        /// </summary>
        public webView.hashUrl Favorite
        {
            get
            {
                return get("favorite", Id);
            }
        }
    }
}
